<?php
class Deptmodel extends Model {
	function Deptmodel() {
		parent::Model();
	}
	
	function show_all_dept() {
		$this->db->select('*');
		$this->db->from('dept');
		$this->db->order_by('dept_id','asc');
		
		return $this->db->get();
	}
	
	function update_prod($id) {
		$this->db->select('*');
		$this->db->from('dept');
		$this->db->where('dept_id',$id);
		
		return $this->db->get();
	}
	function deptname($id,$depts) {
		$this->db->where('dept_id',$id);
		$this->db->update('dept',$depts);
	}
	function show_id_dept() {
		$this->db->select('*');
		$this->db->from('dept');
		$this->db->order_by('dept_id','desc');
		$this->db->limit('1');
		
		return $this->db->get();
	}
	function create_dept($depts) {
		$this->db->insert('dept',$depts);
	}
	
	function delete_dept($id) {
		$this->db->where('dept_id',$id);
		$this->db->delete('dept');
	}
	function sProd() {
		$this->db->select('*');
		$this->db->from('product');
		
		return $this->db->get();
	}
	function showDept($id) {
		$this->db->select('a.*,b.prod_id,b.product,c.*');
		$this->db->from('dept_detail a,product b,dept c');
		$this->db->where('a.dept_id =c.dept_id and a.prod_id = b.prod_id');
		$this->db->where('a.dept_id',$id);
		
		return $this->db->get();
	}
	function showDept2($id) {
		$this->db->select('*');
		$this->db->from('dept ');
		
		$this->db->where('dept_id',$id);
		
		return $this->db->get();
	}
	function delete_det($id) {
		$this->db->where('det_id',$id);
		$this->db->delete('dept_detail');
	}
}
?>